package utils

import "encoding/json"

func ToJsonString(v any) (string, error) {
	buffer, err := json.Marshal(v)
	if err != nil {
		return "", err
	}
	return string(buffer), nil
}

func FromJsonString(jsonString string, v any) error {
	return json.Unmarshal([]byte(jsonString), v)
}

func ValidateJsonString(jsonString string) bool {
	return json.Valid([]byte(jsonString))
}
